const numberToChineseValue = (numStr) => {
    const num = Number(numStr)
    if (isNaN(num)) return numStr

    const digitToChinese = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九']
    const unit = ['', '十', '百', '千']
    const sectionUnit = ['', '万', '亿', '兆']

    const toSection = (sectionNum) => {
        let str = ''
        let zero = true
        const sectionArr = sectionNum.split('').reverse()
        for (let i = 0; i < sectionArr.length; i++) {
            const n = parseInt(sectionArr[i])
            if (n === 0) {
                if (!zero) {
                    zero = true
                    str = digitToChinese[0] + str
                }
            } else {
                zero = false
                str = digitToChinese[n] + unit[i] + str
            }
        }
        return str.replace(/零+$/g, '')
    }

    const numArr = numStr.split('').reverse().join('').match(/.{1,4}/g) || []
    let result = ''
    for (let i = 0; i < numArr.length; i++) {
        const section = toSection(numArr[i].split('').reverse().join(''))
        if (section !== '') {
            result = section + sectionUnit[i] + result
        } else {
            if (!result.startsWith('零')) result = '零' + result
        }
    }

    result = result.replace(/^一十/, '十')
    result = result.replace(/零+/g, '零')
    result = result.replace(/零+$/g, '')

    return result
}
console.log(numberToChineseValue('18069788533'))